$(function() {
});
var DiscountDetailsApp = function(){
	var pageSize = 10; //每页显示条数初始化，修改显示条数，修改这里即可
	var pCount = 0;
	var pagecur;
	return{
		//立即购买
		buynow:function(id){
			console.log("seediscount"+id);
			var json="[{\"goodsId\":"+id+",\"num\":1}]";
			window.location.href=$("#APP_ROOT_PATH").val() + "order/confirm?json="+json;
		},
		//立即参加活动
		joinnow:function(id){
				mui.util.Ajax.asyncGET(
						$("#APP_ROOT_PATH").val() + "discount/join", {
							"discountid": id
						},
						function(data) {
//							console.log(data);
							if(!isNaN(data)&&data >0) {
								layer.open({
									    content: '参与成功',
									    skin: 'msg',
									    time: 2 //2秒后自动关闭
								});
								window.location.href=$("#APP_ROOT_PATH").val() + "discount/memberdetails?discountid="+data;
							}else{
								layer.open({
									    content: data.message,
									    skin: 'msg',
									    time: 2 //2秒后自动关闭
								});
							}
						},
						function() {

						},
						function() {
							
						},
						function() {
						}
					)
		},
	}
}();